/*
 * Copyright (C) 2016 alchemystar, Inc. All Rights Reserved.
 */
package com.eblly.util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * @Author eblly
 */
public class SqlUtil {

    /**
     * 执行sql
     *
     * @param conn
     * @param sql
     * @return
     */
    public static ResultSet executeSql(Connection conn, String sql) {
        try {
            Statement stmt = conn.createStatement();
            stmt.setQueryTimeout(20);
            ResultSet rs = stmt.executeQuery(sql);

            return rs;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

//    public static void ddl(Connection conn, String sql) {
//        try (Statement stmt = conn.createStatement()) {
//            stmt.setQueryTimeout(200);
//            stmt.execute(sql);
//        } catch (Exception e) {
//            System.out.println("ddl fail");
//            e.printStackTrace();
//        }
//    }
//
//    public static String getDbString(String s) {
//        return "'" + s + "'";
//    }
}
